#include "helper/rocksdb/Options.h"

#include <cassert>

#include "rocksdb/options.h"


namespace helper {
namespace rocksdb {

Options::Options(::rocksdb::Comparator * comparator)
: _options(new ::rocksdb::Options())
, _read(new ::rocksdb::ReadOptions())
, _write(new ::rocksdb::WriteOptions())
{
    if(comparator != nullptr)
        this->comparator(comparator);
}
Options::~Options(){
    this->comparator(nullptr);

    delete _write; _write = nullptr;
    delete _read; _read = nullptr;
    delete _options; _options = nullptr;
}

void Options::comparator(::rocksdb::Comparator * comparator ){
    if(_options->comparator != comparator)
        _options->comparator = comparator;
}
const ::rocksdb::Comparator & Options::comparator() const {
    assert(_options->comparator != nullptr);
    return *_options->comparator;
}

::rocksdb::Options & Options::options(){
    return *_options;
}
const ::rocksdb::Options & Options::options() const{
    return *_options;
}
const ::rocksdb::ReadOptions & Options::read() const {
    return *_read;
}
const ::rocksdb::WriteOptions & Options::write() const {
    return *_write;
}

}//end namespace rocksdb
}//end namespace helper
